import {
  BwComPropSetConstValueComEnum,
  BwCustomComSoltTypeEnum,
  BwCustomComPropDataTypeEnum,
} from '../../../render/models'
import type {
  BwCustomComEmitInfoModel,
  BwCustomComSlotInfoModel,
  BwCustomComPropInfoModel,
} from '../../../render/models'

/** 组件属性 */
const comAttrs: Array<BwCustomComPropInfoModel> = [
  {
    key: 'class',
    name: 'classNames',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'name',
    name: '表单域 model 字段',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: undefined,
    remark: '在使用 validate、resetFields 方法的情况下，该属性是必填的',
  },
  {
    key: 'tooltip',
    name: '配置提示信息',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: undefined,
    remark: '',
  },
  {
    key: 'label',
    name: '标题',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: '表单项',
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: undefined,
    remark: '',
  },
  {
    key: 'labelCol',
    name: '标题栅格占位',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.colSpan,
    constValueSetComProps: undefined,
    remark: '',
  },
  {
    key: 'wrapperCol',
    name: '控件栅格占位',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.colSpan,
    constValueSetComProps: undefined,
    remark: '',
  },
  {
    key: 'labelAlign',
    name: '标题对齐方式',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: 'left',
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        { value: 'left', label: '左对齐' },
        { value: 'right', label: '右对齐' },
      ],
    }),
    remark: '',
  },
  {
    key: 'colon',
    name: '子项元素是否使用冒号',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'true',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },

  {
    key: 'autoLink',
    name: '是否自动关联表单域	',
    isRequire: true,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'required',
    name: '是否必填	',
    isRequire: true,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '如不设置，则会根据校验规则自动生成',
  },
  {
    key: 'rules',
    name: '表单验证规则',
    isRequire: false,
    dataType: [
      BwCustomComPropDataTypeEnum.object,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'help',
    name: '验证提示信息',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '如不设置，则会根据校验规则自动生成',
  },
  {
    key: 'extra',
    name: '额外的提示信息',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '当需要错误信息和提示文案同时出现时，可以使用这个',
  },
  {
    key: 'validateFirst',
    name: '验证不通过是否立即停止验证',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'false',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '当某一规则校验不通过时，是否停止剩下的规则的校验',
  },
  {
    key: 'validateStatus',
    name: '校验状态',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: 'false',
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        { value: 'success', label: '验证成功' },
        { value: 'warning', label: '验证警告' },
        { value: 'error', label: '验证错误' },
        { value: 'validating', label: '验证进行中' },
      ],
    }),
    remark: '',
  },
  {
    key: 'hasFeedback',
    name: '校验状态图标',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'false',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '配合 validateStatus 属性使用, 建议只配合 Input 组件使用',
  },
  {
    key: 'validateTrigger',
    name: '验证规则触发时机',
    isRequire: false,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValue: 'change',
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
]

/** 组件事件 */
const comEmits: Array<BwCustomComEmitInfoModel> = []

/** 组件插槽 */
const comSlots: Array<BwCustomComSlotInfoModel> = [
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'default',
      slotName: '默认插槽',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotName: '文案插槽',
      slotCode: 'label',
    },
  },
]

export const antFormItemInfo = {
  comAttrs,
  comEmits,
  comSlots,
}
